﻿using System;
using System.Web.UI;


namespace mojoPortal.Web.RS.SBM
{
    public partial class RSManageEstimate : RSBasePage
    {
        int _companyid = 0;
        int _estimateid = 0;
        int _locationid = 0;

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["Estimateid"] != null)
                _estimateid = Convert.ToInt32(Request.QueryString["estimateid"].ToString());
            if (Request.QueryString["locationid"] != null)
                _locationid = Convert.ToInt32(Request.QueryString["locationid"].ToString());

            if (!Page.IsPostBack)
            {
                InitializeReadyServicePage();
                RSUserIdentity userIdentity = GetRSUserIdentity();
                _companyid = userIdentity.RSCompanyId;

                if (_companyid > 0)
                {
                    if (Request.QueryString["action"] == "add")
                        SetRSPageHeader("Create Estimate");
                    else
                        SetRSPageHeader("Edit Estimate");
                    ucLocationHeaderControl.LoadLocationHeader(_companyid, _locationid);
                    if(_companyid > 0 && _locationid > 0)
                        ucEstimateControl.LoadEstimateDataByID(_companyid, _locationid, _estimateid);
                }
            }
        }

    }
}